home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1999 March / EnigmA AMIGA RUN 35 (1999)(G.R. Edizioni)(IT)[!][issue 1999-03].iso / cd-sup / viruscheckerii / arexx / virus_checkerii.dopus5 < prev   
Text File  |  1999-01-01  |  7KB  |  192 lines

  1. /* Virus_Checker7 for Directory Opus 5 and Virus_Checker 7.
  2.    By Leo Davidson ("Nudel", Pot-Noodle/Gods'Gift Utilities)
  3.  
  4. $VER: Virus_Checker7 1.3 (12.11.97)
  5.  
  6.    Updated by Alex van Niel
  7.  
  8.    NOTE: This script _requires_ DOpus v5.11 or above and Virus_Checker II v1.0
  9.    or above.
  10.  
  11.    If you include the path of a file/dir on the command line, using a {}, only
  12.    this file/dir will be tested. If you omit the {}, the program will check
  13.    all selected files and directories in the SOURCE lister for viruses.
  14.  
  15.    If Virus_Checker's ARexx port is not found, the program will be run for
  16.    you (you should edit the path below). This means the script may fail if
  17.    you give an incorrect path to the Virus_CheckerII program.
  18.  
  19.    If the Virus_Checker's ARexx port takes over a minute to appear, an error
  20.    requester will appear on the DOpus screen and the script will quit.
  21.  
  22.    If Virus_CheckerII was running to start with, it will be left running after
  23.    the script has completed. Otherwise, it will be removed from memory.
  24.  
  25.    When a virus is detected a beep will sound and once all files have been
  26.    checked you will get a requester with a list of infected files (including
  27.    the type of virus). It is possible that the requester will fail to
  28.    appear if it becomes too large to fit on the screen. The script will
  29.    detect when this happens and output the results to a shell window instead.
  30.  
  31.    Thanks to John Veldthuis <johnv@tower.actrix.gen.nz> for writting
  32.    Virus_CheckerII, allowing me access to the VC7 beta versions, and for giving
  33.    me a virus-infected file (!) to test this script with.
  34.  
  35. For a "check selected files for viruses" function, call as:
  36. ------------------------------------------------------------------------------
  37. ARexx        DOpus5:ARexx/Virus_Checker7.dopus5 {Qp} {Ql}
  38. ------------------------------------------------------------------------------
  39. Turn off all switches.
  40.  
  41.  
  42. For an "Un-LhA to a directory and check for viruses" function, call as:
  43. ------------------------------------------------------------------------------
  44. AmigaDOS    C:LHA -M x {fu} {d}{ou-}/
  45. ARexx        DOpus5:ARexx/Virus_Checker7.dopus5 {Qp} {Ql} {d}{o-}
  46. ------------------------------------------------------------------------------
  47. Switches: Do all files
  48.           Output to window
  49.           Rescan dest
  50.           Window close button
  51.  
  52.    v1.00 -> v1.01 - Some minor tidying up.
  53.                     Now checks to make sure the DOPUS.x port exists.
  54.     v1.02 -> v1.3 - Now uses Show() instead of ShowList(). (Thanks Stoebi)
  55.                     Style Guide compliant version numbering and $VER string.
  56.  
  57. */
  58. /*- Path to Virus_CheckerII command ------------------------------------------*/
  59. Virus_CheckerII = "DH0:Tools/Harddrive/VirusKillers/Virus_CheckerII"
  60. /*--------------------------------------------------------------------------*/
  61. options results
  62. options failat 99
  63. signal on syntax;signal on ioerr        /* Error trapping */
  64. parse arg DOpusPort source_handle.0 FilePath
  65. DOpusPort = Strip(DOpusPort,"B",'" ')
  66. source_handle.0 = Strip(source_handle.0,"B",'" ')
  67. FilePath = Strip(FilePath,"B",'" ')
  68.  
  69. If DOpusPort="" THEN Do
  70.     Say "Not correctly called from Directory Opus 5!"
  71.     Say "Load this ARexx script into an editor for more info."
  72.     EXIT
  73.     END
  74. If ~Show("P",DOpusPort) Then Do
  75.     Say DOpusPort "is not a valid port."
  76.     EXIT
  77.     End
  78. Address value DOpusPort
  79.  
  80. Quit_After = "NO"
  81. If ~Show("P","Virus_CheckerII") Then Do
  82.     Address Command Virus_CheckerII
  83.     Quit_After = "YES"
  84.     TickTick = Time(M)
  85.     Do While ~Show("P","Virus_CheckerII")
  86.         IF Time(M) - TickTick > 1 Then Do
  87.             dopus request '"Error loading Virus_CheckerII!'|| '0a'x ||'Check its command-line in the ARexx script itself." OK'
  88.             EXIT
  89.             END
  90.         END
  91.     END
  92.  
  93. /* If file/dir-path was specified on command line, check it, else
  94.    go through all the selected ones. */
  95.  
  96. BadList = ""
  97. BadNumber = 0
  98.  
  99. /*
  100. lister query source stem source_handle.
  101. IF source_handle.count = 0 | source_handle.count = "SOURCE_HANDLE.COUNT" Then Do
  102.     dopus request '"You must have a SOURCE lister!" OK'
  103.     EXIT
  104.     End
  105. */
  106.  
  107. If FilePath = "" Then Do
  108.     lister set source_handle.0 busy 1
  109.  
  110.     lister query source_handle.0 numselentries    /* Get info about selected */
  111.     Lister_NumSelEnt = RESULT            /* entries & path to them */
  112.     lister query source_handle.0 path
  113.     Lister_Path = Strip(RESULT,"B",'"')
  114.  
  115.     lister set source_handle.0 progress Lister_NumSelEnt "Checking for viruses..."
  116.  
  117.     Do i=1 to Lister_NumSelEnt
  118.         lister query source_handle.0 abort
  119.         If RESULT=1 Then BREAK
  120.         lister query source_handle.0 firstsel
  121.         Temp_Name = Strip(RESULT,"B",'"')
  122.         lister select source_handle.0 Temp_Name 0
  123.         Temp_Path = Lister_Path || Temp_Name
  124.         lister set source_handle.0 progress name Temp_Name
  125.         lister set source_handle.0 progress count i
  126.         Address "Virus_CheckerII" "Scan "||Temp_Path
  127.         If VCHECK.0.0 ~= 0 Then Do
  128.             command beep
  129.             Do x=1 to VCHECK.0.0
  130.                 BadNumber = BadNumber + 1
  131.                 BadList = BadList || '0a'x || VCHECK.x.1 ||"  (" || VCHECK.x.2 || ")"
  132.                 END
  133.             END
  134.         END
  135.     lister clear source_handle.0 progress
  136.     End
  137.  
  138. ELSE Do
  139.     lister set source_handle.0 progress "-1" "Checking for viruses..."
  140.     Address "Virus_CheckerII" "Scan "||FilePath
  141.     If VCHECK.0.0 ~= 0 Then Do
  142.         command beep
  143.         Do x=1 to VCHECK.0.0
  144.             BadNumber = BadNumber + 1
  145.             BadList = BadList || '0a'x || VCHECK.x.1 ||"  (" || VCHECK.x.2 || ")"
  146.             END
  147.         END
  148.     lister clear source_handle.0 progress
  149.     End
  150.  
  151. If BadNumber > 0 Then Do
  152.     If BadNumber = 1 Then
  153.         BadNote = "The following file is infected:"
  154.     Else
  155.         BadNote = "The following files are infected:"
  156.     BadList = "*VIRUS WARNING*" || '0a'x || BadNote || '0a'x || "(Virus name in parenthesis)" || '0a'x || BadList
  157.  
  158.     dopus request '"'||BadList||'" OK'
  159.  
  160. /* As there is only one gadget which returns "RC = 1", when "RC = 0" it means
  161.    that the requester failed to appear. This will happen when the list is too
  162.    long or wide to fit on the screen, which could easily happen with a virus
  163.    which has spread itself to many files!
  164.  
  165.    So, if the requester failed, the output will be sent to a shell window.
  166.    It would be nice to be able to use the user's defined output-window
  167.    size but there is (currently) no way of obtaining this. */
  168.  
  169.     IF RC = 0 Then Do
  170.         dopus request '"*VIRUS WARNING*' || '0a'x || 'List too large for requester' || '0a'x || 'and will be output to a shell..." OK'
  171.         Open(Output_Shell,"CON:0/1/640/200/Virus Warning/CLOSE/WAIT","W")
  172.         WriteLN(Output_Shell,BadList)
  173.         Close(Output_Shell)
  174.         END
  175.     END
  176.  
  177. /*-- Restore the Lister for normal use --------------------------------------*/
  178. syntax:;ioerr:                /* In case of error, jump here */
  179. END_PART_2:
  180.  
  181. lister clear source_handle.0 progress
  182.  
  183. If FilePath = "" Then Do
  184.     lister refresh source_handle.0
  185.     lister set source_handle.0 busy 0
  186.     END
  187.  
  188. END_PART:
  189. If Quit_After = "YES" Then Address "Virus_CheckerII" QUIT
  190.  
  191. EXIT
  192.